home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbpong1a / cdxvbcd.cls < prev    next >
Text File  |  1999-08-09  |  4KB  |  253 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "CDXVBCD"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. '***************************************************************
  15. 'Windows API/Global Declarations for :*Make your own CD-Player!*
  16. '     Fixed!
  17. '***************************************************************
  18. 'Copy and Paste the following into a Class Module(.cls)
  19. 'not a bas
  20.  
  21.  
  22. Private Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
  23.  
  24.  
  25. Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
  26.  
  27.  
  28. Function StartPlay()
  29.  
  30.  
  31.     mciSendString "play cd", 0, 0, 0
  32. End Function
  33.  
  34.  
  35.  
  36.  
  37. Function SetTrack(Track%)
  38.  
  39.  
  40.     mciSendString "seek cd to " & Str(Track), 0, 0, 0
  41. End Function
  42.  
  43.  
  44.  
  45.  
  46. Function StopPlay()
  47.  
  48.  
  49.     mciSendString "stop cd wait", 0, 0, 0
  50. End Function
  51.  
  52.  
  53.  
  54.  
  55. Function PausePlay()
  56.  
  57.  
  58.     mciSendString "pause cd", 0, 0, 0
  59. End Function
  60.  
  61.  
  62.  
  63.  
  64. Function EjectCD()
  65.  
  66.  
  67.     mciSendString "set cd door open", 0, 0, 0
  68. End Function
  69.  
  70.  
  71.  
  72.  
  73. Function CloseCD()
  74.  
  75.  
  76.     mciSendString "set cd door closed", 0, 0, 0
  77. End Function
  78.  
  79.  
  80.  
  81.  
  82. Function UnloadAll()
  83.  
  84.  
  85.     mciSendString "close all", 0, 0, 0
  86. End Function
  87.  
  88.  
  89.  
  90.  
  91. Function SetCDPlayerReady()
  92.  
  93.  
  94.     mciSendString "open cdaudio Alias cd wait shareable", 0, 0, 0
  95. End Function
  96.  
  97.  
  98.  
  99.  
  100. Function SetFormat_tmsf()
  101.  
  102.  
  103.     mciSendString "set cd time format tmsf wait", 0, 0, 0
  104. End Function
  105.  
  106.  
  107.  
  108.  
  109. Function SetFormat_milliseconds()
  110.  
  111.  
  112.     mciSendString "set cd time format milliseconds", 0, 0, 0
  113. End Function
  114.  
  115.  
  116.  
  117.  
  118. Function CheckCD%()
  119.  
  120.  
  121.     Dim s As String * 30
  122.     mciSendString "status cd media present", s, Len(s), 0
  123.     CheckCD = s
  124. End Function
  125.  
  126.  
  127.  
  128.  
  129. Function GetNumTracks%()
  130.  
  131.  
  132.     Dim s As String * 30
  133.     mciSendString "status cd number of tracks wait", s, Len(s), 0
  134.     GetNumTracks = CInt(Mid$(s, 1, 2))
  135. End Function
  136.  
  137.  
  138.  
  139.  
  140. Function GetCDLength$()
  141.  
  142.  
  143.     Dim s As String * 30
  144.     mciSendString "status cd length wait", s, Len(s), 0
  145.     GetCDLength = s
  146. End Function
  147.  
  148.  
  149.  
  150.  
  151. Function GetTrackLength$(TrackNum%)
  152.  
  153.  
  154.     Dim s As String * 30
  155.     mciSendString "status cd length track " & TrackNum, s, Len(s), 0
  156.     GetTrackLength = s
  157. End Function
  158.  
  159.  
  160.  
  161.  
  162. Sub GetCDPosition(Track%, Min%, Sec%)
  163.  
  164.  
  165.     Dim s As String * 30
  166.     mciSendString "status cd position", s, Len(s), 0
  167.     Track = CInt(Mid$(s, 1, 2))
  168.     Min = CInt(Mid$(s, 4, 2))
  169.     Sec = CInt(Mid$(s, 7, 2))
  170. End Sub
  171.  
  172.  
  173.  
  174.  
  175. Function CheckIfPlaying%()
  176.  
  177.  
  178.     CheckIfPlaying = 0
  179.     Dim s As String * 30
  180.     mciSendString "status cd mode", s, Len(s), 0
  181.     If Mid$(s, 1, 7) = "playing" Then CheckIfPlaying = 1
  182. End Function
  183.  
  184.  
  185. '|---------------------|
  186. '|---Automated Tasks---|
  187. 'V---------------------V
  188.  
  189.  
  190. Function SeekCDtoX(Track%)
  191.  
  192.  
  193.     StopPlay
  194.     SetTrack Track
  195.     StartPlay
  196. End Function
  197.  
  198.  
  199.  
  200.  
  201. Function ReadyDevice()
  202.  
  203.  
  204.     UnloadAll
  205.     SetCDPlayerReady
  206.     SetFormat_tmsf
  207. End Function
  208.  
  209.  
  210.  
  211.  
  212. Function FastForward(Spd%)
  213.  
  214.  
  215.     Dim s As String * 40
  216.     SetFormat_milliseconds
  217.     mciSendString "status cd position wait", s, Len(s), 0
  218.     CheckIfPlaying%
  219.  
  220.  
  221.     If CheckIfPlaying = 1 Then
  222.         mciSendString "play cd from " & CStr(CLng(s) + Spd), 0, 0, 0
  223.     Else
  224.         mciSendString "seek cd to " & CStr(CLng(s) + Spd), 0, 0, 0
  225.     End If
  226.  
  227.  
  228.     SetFormat_tmsf
  229. End Function
  230.  
  231.  
  232.  
  233.  
  234. Function ReWind(Spd%)
  235.  
  236.  
  237.     Dim s As String * 40
  238.     SetFormat_milliseconds
  239.     mciSendString "status cd position wait", s, Len(s), 0
  240.     CheckIfPlaying%
  241.  
  242.  
  243.     If CheckIfPlaying = 1 Then
  244.         mciSendString "play cd from " & CStr(CLng(s) - Spd), 0, 0, 0
  245.     Else
  246.         mciSendString "seek cd to " & CStr(CLng(s) - Spd), 0, 0, 0
  247.     End If
  248.  
  249.  
  250.     SetFormat_tmsf
  251. End Function
  252.  
  253.